<#assign base = request.contextPath />
<!doctype html>
<html lang="en">
<head>
    <base id="base" href="${base}">
	<meta charset="UTF-8">
	<title>盒老师</title>
	<meta name="keywords" content="盒老师">
	<meta name="content" content="盒老师">

    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <link type="text/css" rel="stylesheet" href="${base}/login/css/login.css">
    <script type="text/javascript" src="${base}/login/js/jquery.min.js"></script>
    <script>
        var countdown=30;
        function settime(obj) {
            if (countdown == 0) {
                obj.removeAttribute("disabled");
                obj.value="获取验证码";
                countdown = 30;
                return;
            } else {
                if(countdown==30){
                    cellphone();
                }
                obj.setAttribute("disabled", true);
                obj.value="重新发送(" + countdown + ")";
                countdown--;
            }
            setTimeout(function() {
                    settime(obj) }
                ,1000)
        }
        function cellphone(){
            var email=$(".email").val();
            $.ajax({
                type: "post",
                url: "user/judgeUser",
                data:"email="+email,
                success:function(data){
                    if(data.result){
                        $.ajax({
                            type: "get",
                            url: "gold/sendEmailCode",
                            data:"email="+email,
                            success:function(data){
                                alert("发送成功")
                            },
                            error: function(error){
                                alert( "发送失败" );
                            }
                        });
                    }else{
                        alert("您的邮箱已被注册!")
                        countdown =0;
                    }
                }
            });
        }
        //验证码验证
    $(function () {
        $(".btn_jiaoyan").click(function () {
            var email=$(".email").val();
            var code= $(".yanzm").val();
            $.ajax({
                type: "post",
                url: "gold/chekcEmail",
                data:"email="+email+"&code="+code,
                success:function(data){
                    if (data.message=="超时"){
                        alert("验证码超时")
                    }else if(data.message=="失败"){
                        alert("验证码错误")
                    }else if (data.message=="验证码正确"){
                        $(".email").hide();
                        $(".btn_jiaoyan").hide();
                        $("#btn").hide();
                        $(".yanzm").hide();
                        $(".phone").show();
                        $(".possword").show();
                        $("#kai_xi").show();
                        $(".btn_zhuce").show();
                        $(".bj_bai").css({"float":"left","width":"314px","height":"350px","padding-left":"50px","background":"#FFF"});
                    }
                }
            });
        });
    });

    </script>
</head>
<body class="login_bj" >

<div class="zhuce_body">
	<div class="logo"><a href="#"><img src="${base}/login/images/logo.png" width="114" height="54" border="0"></a></div>
    <div class="zhuce_kong">
    	<div class="zc">
        	<div class="bj_bai">
            <h3>欢迎注册</h3>
       	  	  <form action="" method="post">
                  <input name="email" type="text" class="kuang_txt email" placeholder="邮箱">
                  <input type="button" id="btn" class="btn_tijiao" value="获取验证码"onclick="settime(this)" />
                  <input name="code" type="text" class="kuang_txt yanzm" placeholder="验证码">
                  <input type="button" class="btn_jiaoyan" value="提交">
                  <input name="nickName" type="text" class="kuang_txt phone" style="display:none" placeholder="称呼">
                  <input name="loginName" type="text" class="kuang_txt phone" style="display:none" placeholder="用户名">
                  <input name="password" type="password" class="kuang_txt possword" style="display:none" placeholder="密码">
                  <div id="kai_xi"  style="display:none">
                      <input name="" type="checkbox" value=""><span>已阅读并同意<a href="#" target="_blank"><span class="lan">《XXXXX使用协议》</span></a></span>
                </div>
                <input name="注册" type="submit" class="btn_zhuce" value="注册" style="display:none">
                </form>
            </div>
        </div>
    </div>
</div>

</body>
</html>